package com.kmxd.ams.core.config;

import cn.hutool.core.collection.ListUtil;
import java.lang.reflect.Method;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zuolg
 */
@Configuration
public class MyCacheConfig {
  private final String seperator = ":";

  @Bean("myKeyGenerator")
  public KeyGenerator keyGenerator() {
    return new KeyGenerator() {
      @Override
      public Object generate(Object target, Method method, Object... params) {
        String str = ListUtil.of(params).toString();
        return method.getName() + seperator + str;
      }
    };
  }
}
